/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package motiveai.factors;

import java.util.Map;
import java.util.HashMap;
import motiveai.components.BehaviourEntity;
import motiveai.components.MotiveAI;

/**
 *
 * @author oxplay
 */
public class EnvironmentSharedData {

    private Map<String, BehaviourEntity> behaviourMemory = new HashMap<String, BehaviourEntity>();
    private float performance = 0;
    private long maxCountOfBehave = 0;
    private int hashCode = 0;

    public long getLearnCountLeft(MotiveAI manager) {
        return manager.getMaxCountLearn() - maxCountOfBehave;
    }

    public EnvironmentSharedData(int hashCode, float performance) {
        this.hashCode = hashCode;
        this.performance = performance;
    }

    public int getHashCode() {
        return hashCode;
    }

    public float getPerformance() {
        return performance;
    }

    public void setMaxCountOfBehave(long maxCountOfBehave) {
        this.maxCountOfBehave = maxCountOfBehave;
    }

    public long getMaxCountOfBehave() {
        return maxCountOfBehave;
    }

    public Map<String, BehaviourEntity> getBehaviourMemory() {
        return behaviourMemory;
    }

    public void addBehaviourMemory(BehaviourEntity behaviour) {
        String className = behaviour.getClass().getSimpleName();
        BehaviourEntity actualBehaviour = behaviourMemory.get(className);
        if (actualBehaviour == null) {
            behaviourMemory.put(className, behaviour);
            actualBehaviour = behaviour;
        }
        if (maxCountOfBehave < actualBehaviour.getCountMemory()) {
            maxCountOfBehave = actualBehaviour.getCountMemory();
        }
    }
}
